package com.abc.pay.client;

import lombok.extern.slf4j.Slf4j;

import javax.net.ssl.SSLSocketFactory;

@Slf4j
public class MerchantConfig {
    public static MerchantPara iPara = null;
    public static SSLSocketFactory iSSLSocketFactory = null;
    public static MerchantConfig uniqueInstanceOf_MerchantConfig = null;

    private MerchantConfig() throws TrxException {
        MerchantParaFactory factory = new MerchantParaFromFile();
        iPara = factory.getMerchantPara();
    }

    private static synchronized void syncInit() throws TrxException {
        if (uniqueInstanceOf_MerchantConfig == null) {
            uniqueInstanceOf_MerchantConfig = new MerchantConfig();
        }
    }

    public static MerchantConfig getUniqueInstance() throws TrxException {
        if (uniqueInstanceOf_MerchantConfig == null) {
            syncInit();
        }
        return uniqueInstanceOf_MerchantConfig;
    }

    public MerchantPara getPara() {
        return iPara;
    }

    public static SSLSocketFactory getSSLSocketFactory() {
        return iSSLSocketFactory;
    }
}
